Location: BondGraph Basic @ 24365f78f734 / BG Tutorial Mechanical Systems / Pendulum_Single.cellml

Author:
Soroush Safaei <ssaf006@aucklanduni.ac.nz>
Date:
2018-10-15 16:33:56+13:00
Desc:
added two examples
Permanent Source URI:
https://models.fieldml.org/workspace/43b/rawfile/24365f78f734066f143d513ad0303bf566dd5606/BG Tutorial Mechanical Systems/Pendulum_Single.cellml

<?xml version='1.0'?>
<model name="SinglePendulum" xmlns="http://www.cellml.org/cellml/1.1#" xmlns:cellml="http://www.cellml.org/cellml/1.1#" xmlns:xlink="http://www.w3.org/1999/xlink">
    <import xlink:href="Units.cellml">
        <units name="m_per_s" units_ref="m_per_s"/>
        <units name="m_per_s2" units_ref="m_per_s2"/>
        <units name="rad_per_s" units_ref="rad_per_s"/>
        <units name="rad_per_s2" units_ref="rad_per_s2"/>
        <units name="J_per_m" units_ref="J_per_m"/>
        <units name="J_per_rad" units_ref="J_per_rad"/>
        <units name="J_per_m2" units_ref="J_per_m2"/>
        <units name="J_s_per_rad" units_ref="J_s_per_rad"/>
        <units name="J_s_per_m" units_ref="J_s_per_m"/>
        <units name="J_s_per_m2" units_ref="J_s_per_m2"/>
        <units name="J_s2_per_m2" units_ref="J_s2_per_m2"/>
    </import>
    <component name="control">
        <variable initial_value="90" name="q0_theta_1" units="dimensionless"/>
        <variable initial_value="90" name="q_theta_1" public_interface="out" units="dimensionless"/>
        <variable initial_value="0.5" name="l_1" public_interface="out" units="metre"/>
        <variable initial_value="20.0" name="I_1" public_interface="out" units="J_s2_per_m2"/>
        <variable name="q_x_1_tmp" public_interface="in" units="metre"/>
        <variable name="q_y_1_tmp" public_interface="in" units="metre"/>
        <variable name="q_xc_1_tmp" public_interface="in" units="metre"/>
        <variable name="q_yc_1_tmp" public_interface="in" units="metre"/>
        <variable name="q_x_2_tmp" public_interface="in" units="metre"/>
        <variable name="q_y_2_tmp" public_interface="in" units="metre"/>
        <variable name="q_x_1" public_interface="out" units="metre"/>
        <variable name="q_y_1" public_interface="out" units="metre"/>
        <variable name="q_xc_1" public_interface="out" units="metre"/>
        <variable name="q_yc_1" public_interface="out" units="metre"/>
        <variable name="q_x_2" public_interface="out" units="metre"/>
        <variable name="q_y_2" public_interface="out" units="metre"/>
        <variable name="t" public_interface="out" units="second"/>
        <math xmlns="http://www.w3.org/1998/Math/MathML">
            <apply>
                <eq/>
                <ci>q_x_1</ci>
                <ci>q_x_1_tmp</ci>
            </apply>
            <apply>
                <eq/>
                <ci>q_y_1</ci>
                <ci>q_y_1_tmp</ci>
            </apply>
            <apply>
                <eq/>
                <ci>q_xc_1</ci>
                <apply>
                    <plus/>
                    <ci>q_xc_1_tmp</ci>
                    <apply>
                        <times/>
                        <ci>l_1</ci>
                        <apply>
                            <sin/>
                            <apply>
                                <divide/>
                                <apply>
                                    <times/>
                                    <ci>q0_theta_1</ci>
                                    <pi/>
                                </apply>
                                <cn cellml:units="dimensionless">180</cn>
                            </apply>
                        </apply>
                    </apply>
                </apply>
            </apply>
            <apply>
                <eq/>
                <ci>q_yc_1</ci>
                <apply>
                    <minus/>
                    <ci>q_yc_1_tmp</ci>
                    <apply>
                        <times/>
                        <ci>l_1</ci>
                        <apply>
                            <cos/>
                            <apply>
                                <divide/>
                                <apply>
                                    <times/>
                                    <ci>q0_theta_1</ci>
                                    <pi/>
                                </apply>
                                <cn cellml:units="dimensionless">180</cn>
                            </apply>
                        </apply>
                    </apply>
                </apply>
            </apply>
            <apply>
                <eq/>
                <ci>q_x_2</ci>
                <apply>
                    <plus/>
                    <ci>q_x_2_tmp</ci>
                    <apply>
                        <times/>
                        <apply>
                            <plus/>
                            <ci>l_1</ci>
                            <ci>l_1</ci>
                        </apply>
                        <apply>
                            <sin/>
                            <apply>
                                <divide/>
                                <apply>
                                    <times/>
                                    <ci>q0_theta_1</ci>
                                    <pi/>
                                </apply>
                                <cn cellml:units="dimensionless">180</cn>
                            </apply>
                        </apply>
                    </apply>
                </apply>
            </apply>
            <apply>
                <eq/>
                <ci>q_y_2</ci>
                <apply>
                    <minus/>
                    <ci>q_y_2_tmp</ci>
                    <apply>
                        <times/>
                        <apply>
                            <plus/>
                            <ci>l_1</ci>
                            <ci>l_1</ci>
                        </apply>
                        <apply>
                            <cos/>
                            <apply>
                                <divide/>
                                <apply>
                                    <times/>
                                    <ci>q0_theta_1</ci>
                                    <pi/>
                                </apply>
                                <cn cellml:units="dimensionless">180</cn>
                            </apply>
                        </apply>
                    </apply>
                </apply>
            </apply>
        </math>
    </component>
    <component name="pendulum">
        <variable name="t" public_interface="in" units="second"/>
        <variable name="l_1" public_interface="in" units="metre"/>
        <variable name="I_1" public_interface="in" units="J_s2_per_m2"/>
        <!--State variables-->
        <variable name="q_theta_1" public_interface="in" units="dimensionless"/>
        <variable initial_value="0" name="q_x_1" public_interface="out" units="metre"/>
        <variable initial_value="0" name="q_y_1" public_interface="out" units="metre"/>
        <variable initial_value="0" name="q_xc_1" public_interface="out" units="metre"/>
        <variable initial_value="0" name="q_yc_1" public_interface="out" units="metre"/>
        <variable initial_value="0" name="q_x_2" public_interface="out" units="metre"/>
        <variable initial_value="0" name="q_y_2" public_interface="out" units="metre"/>
        <variable name="v_theta_1" units="rad_per_s"/>
        <variable name="v_1" units="rad_per_s"/>
        <variable name="v_2" units="rad_per_s"/>
        <variable name="v_3" units="rad_per_s"/>
        <variable name="v_4" units="rad_per_s"/>
        <variable name="v_xc_1" units="m_per_s"/>
        <variable name="v_yc_1" units="m_per_s"/>
        <variable name="v_x_2" units="m_per_s"/>
        <variable name="v_y_2" units="m_per_s"/>
        <variable name="u_xc_1" units="J_per_m"/>
        <variable name="u_yc_1" units="J_per_m"/>
        <variable name="u_theta_1" units="J_per_rad"/>
        <variable name="u_1" units="J_per_rad"/>
        <variable name="u_2" units="J_per_rad"/>
        <variable name="u_3" units="J_per_rad"/>
        <variable name="u_4" units="J_per_rad"/>
        <variable name="u_x_1" units="J_per_m"/>
        <variable name="u_y_1" units="J_per_m"/>
        <!--&#45;&#45;&#45;&#45;&#45;&#45;-ICs&#45;&#45;&#45;&#45;&#45;&#45;- -->
        <variable initial_value="0" name="p_xc_1" units="J_s_per_m"/>
        <variable initial_value="0" name="p_yc_1" units="J_s_per_m"/>
        <variable initial_value="0" name="p_theta_1" units="J_s_per_rad"/>
        <!--&#45;&#45;&#45;&#45;&#45;&#45;-BCs&#45;&#45;&#45;&#45;&#45;&#45;- -->
        <variable initial_value="0" name="v_x_1" units="m_per_s"/>
        <variable initial_value="0" name="v_y_1" units="m_per_s"/>
        <variable initial_value="0" name="u_x_2" units="J_per_m"/>
        <variable initial_value="0" name="u_y_2" units="J_per_m"/>
        <variable name="u_g_1" units="J_per_m"/>
        <!--Conservation laws-->
        <math xmlns="http://www.w3.org/1998/Math/MathML">
            <apply>
                <eq/>
                <apply>
                    <diff/>
                    <bvar>
                        <ci>t</ci>
                    </bvar>
                    <ci>q_theta_1</ci>
                </apply>
                <apply>
                    <divide/>
                    <apply>
                        <times/>
                        <ci>v_theta_1</ci>
                        <cn cellml:units="dimensionless">180</cn>
                    </apply>
                    <pi/>
                </apply>
            </apply>
            <apply>
                <eq/>
                <apply>
                    <diff/>
                    <bvar>
                        <ci>t</ci>
                    </bvar>
                    <ci>q_x_1</ci>
                </apply>
                <ci>v_x_1</ci>
            </apply>
            <apply>
                <eq/>
                <apply>
                    <diff/>
                    <bvar>
                        <ci>t</ci>
                    </bvar>
                    <ci>q_y_1</ci>
                </apply>
                <ci>v_y_1</ci>
            </apply>
            <apply>
                <eq/>
                <apply>
                    <diff/>
                    <bvar>
                        <ci>t</ci>
                    </bvar>
                    <ci>q_xc_1</ci>
                </apply>
                <ci>v_xc_1</ci>
            </apply>
            <apply>
                <eq/>
                <apply>
                    <diff/>
                    <bvar>
                        <ci>t</ci>
                    </bvar>
                    <ci>q_yc_1</ci>
                </apply>
                <ci>v_yc_1</ci>
            </apply>
            <apply>
                <eq/>
                <apply>
                    <diff/>
                    <bvar>
                        <ci>t</ci>
                    </bvar>
                    <ci>q_x_2</ci>
                </apply>
                <ci>v_x_2</ci>
            </apply>
            <apply>
                <eq/>
                <apply>
                    <diff/>
                    <bvar>
                        <ci>t</ci>
                    </bvar>
                    <ci>q_y_2</ci>
                </apply>
                <ci>v_y_2</ci>
            </apply>
            <apply>
                <eq/>
                <apply>
                    <diff/>
                    <bvar>
                        <ci>t</ci>
                    </bvar>
                    <ci>p_theta_1</ci>
                </apply>
                <ci>u_theta_1</ci>
            </apply>
            <apply>
                <eq/>
                <apply>
                    <diff/>
                    <bvar>
                        <ci>t</ci>
                    </bvar>
                    <ci>p_xc_1</ci>
                </apply>
                <ci>u_xc_1</ci>
            </apply>
            <apply>
                <eq/>
                <apply>
                    <diff/>
                    <bvar>
                        <ci>t</ci>
                    </bvar>
                    <ci>p_yc_1</ci>
                </apply>
                <ci>u_yc_1</ci>
            </apply>
            <apply>
                <eq/>
                <ci>u_theta_1</ci>
                <apply>
                    <minus/>
                    <apply>
                        <plus/>
                        <ci>u_1</ci>
                        <ci>u_2</ci>
                        <ci>u_3</ci>
                        <ci>u_4</ci>
                    </apply>
                </apply>
            </apply>
            <apply>
                <eq/>
                <ci>u_xc_1</ci>
                <apply>
                    <minus/>
                    <ci>u_x_1</ci>
                    <ci>u_x_2</ci>
                </apply>
            </apply>
            <apply>
                <eq/>
                <ci>u_yc_1</ci>
                <apply>
                    <minus/>
                    <apply>
                        <minus/>
                        <ci>u_y_1</ci>
                        <ci>u_y_2</ci>
                    </apply>
                    <ci>u_g_1</ci>
                </apply>
            </apply>
            <apply>
                <eq/>
                <ci>v_xc_1</ci>
                <apply>
                    <minus/>
                    <apply>
                        <plus/>
                        <ci>v_x_1</ci>
                        <ci>v_1</ci>
                    </apply>
                    <ci>v_aux_x</ci>
                </apply>
            </apply>
            <apply>
                <eq/>
                <ci>v_xc_1</ci>
                <apply>
                    <minus/>
                    <ci>v_x_2</ci>
                    <ci>v_2</ci>
                </apply>
            </apply>
            <apply>
                <eq/>
                <ci>v_yc_1</ci>
                <apply>
                    <minus/>
                    <apply>
                        <plus/>
                        <ci>v_y_1</ci>
                        <ci>v_3</ci>
                    </apply>
                    <ci>v_aux_y</ci>
                </apply>
            </apply>
            <apply>
                <eq/>
                <ci>v_yc_1</ci>
                <apply>
                    <minus/>
                    <ci>v_y_2</ci>
                    <ci>v_4</ci>
                </apply>
            </apply>
            <!--Constitutive relations-->
            <apply>
                <eq/>
                <ci>v_theta_1</ci>
                <apply>
                    <divide/>
                    <ci>p_theta_1</ci>
                    <apply>
                        <divide/>
                        <apply>
                            <times/>
                            <ci>I_1</ci>
                            <apply>
                                <power/>
                                <apply>
                                    <plus/>
                                    <ci>l_1</ci>
                                    <ci>l_1</ci>
                                </apply>
                                <cn cellml:units="dimensionless">2</cn>
                            </apply>
                        </apply>
                        <cn cellml:units="dimensionless">3</cn>
                    </apply>
                </apply>
            </apply>
            <apply>
                <eq/>
                <ci>v_xc_1</ci>
                <apply>
                    <divide/>
                    <ci>p_xc_1</ci>
                    <ci>I_1</ci>
                </apply>
            </apply>
            <apply>
                <eq/>
                <ci>v_yc_1</ci>
                <apply>
                    <divide/>
                    <ci>p_yc_1</ci>
                    <ci>I_1</ci>
                </apply>
            </apply>
            <!--Transformations-->
            <apply>
                <eq/>
                <ci>v_1</ci>
                <apply>
                    <times/>
                    <ci>l_1</ci>
                    <apply>
                        <cos/>
                        <apply>
                            <divide/>
                            <apply>
                                <times/>
                                <ci>q_theta_1</ci>
                                <pi/>
                            </apply>
                            <cn cellml:units="dimensionless">180</cn>
                        </apply>
                    </apply>
                    <ci>v_theta_1</ci>
                </apply>
            </apply>
            <apply>
                <eq/>
                <ci>v_2</ci>
                <apply>
                    <times/>
                    <ci>l_1</ci>
                    <apply>
                        <cos/>
                        <apply>
                            <divide/>
                            <apply>
                                <times/>
                                <ci>q_theta_1</ci>
                                <pi/>
                            </apply>
                            <cn cellml:units="dimensionless">180</cn>
                        </apply>
                    </apply>
                    <ci>v_theta_1</ci>
                </apply>
            </apply>
            <apply>
                <eq/>
                <ci>v_3</ci>
                <apply>
                    <times/>
                    <ci>l_1</ci>
                    <apply>
                        <sin/>
                        <apply>
                            <divide/>
                            <apply>
                                <times/>
                                <ci>q_theta_1</ci>
                                <pi/>
                            </apply>
                            <cn cellml:units="dimensionless">180</cn>
                        </apply>
                    </apply>
                    <ci>v_theta_1</ci>
                </apply>
            </apply>
            <apply>
                <eq/>
                <ci>v_4</ci>
                <apply>
                    <times/>
                    <ci>l_1</ci>
                    <apply>
                        <sin/>
                        <apply>
                            <divide/>
                            <apply>
                                <times/>
                                <ci>q_theta_1</ci>
                                <pi/>
                            </apply>
                            <cn cellml:units="dimensionless">180</cn>
                        </apply>
                    </apply>
                    <ci>v_theta_1</ci>
                </apply>
            </apply>
            <apply>
                <eq/>
                <ci>u_1</ci>
                <apply>
                    <times/>
                    <ci>l_1</ci>
                    <apply>
                        <cos/>
                        <apply>
                            <divide/>
                            <apply>
                                <times/>
                                <ci>q_theta_1</ci>
                                <pi/>
                            </apply>
                            <cn cellml:units="dimensionless">180</cn>
                        </apply>
                    </apply>
                    <ci>u_x_1</ci>
                </apply>
            </apply>
            <apply>
                <eq/>
                <ci>u_2</ci>
                <apply>
                    <times/>
                    <ci>l_1</ci>
                    <apply>
                        <cos/>
                        <apply>
                            <divide/>
                            <apply>
                                <times/>
                                <ci>q_theta_1</ci>
                                <pi/>
                            </apply>
                            <cn cellml:units="dimensionless">180</cn>
                        </apply>
                    </apply>
                    <ci>u_x_2</ci>
                </apply>
            </apply>
            <apply>
                <eq/>
                <ci>u_3</ci>
                <apply>
                    <times/>
                    <ci>l_1</ci>
                    <apply>
                        <sin/>
                        <apply>
                            <divide/>
                            <apply>
                                <times/>
                                <ci>q_theta_1</ci>
                                <pi/>
                            </apply>
                            <cn cellml:units="dimensionless">180</cn>
                        </apply>
                    </apply>
                    <ci>u_y_1</ci>
                </apply>
            </apply>
            <apply>
                <eq/>
                <ci>u_4</ci>
                <apply>
                    <times/>
                    <ci>l_1</ci>
                    <apply>
                        <sin/>
                        <apply>
                            <divide/>
                            <apply>
                                <times/>
                                <ci>q_theta_1</ci>
                                <pi/>
                            </apply>
                            <cn cellml:units="dimensionless">180</cn>
                        </apply>
                    </apply>
                    <ci>u_y_2</ci>
                </apply>
            </apply>
        </math>
        <variable initial_value="1e9" name="E_1" units="J_per_m2"/>
        <variable initial_value="1e9" name="E_2" units="J_per_m2"/>
        <variable name="v_aux_x" units="m_per_s"/>
        <variable name="v_aux_y" units="m_per_s"/>
        <variable initial_value="0" name="q_aux_x" units="metre"/>
        <variable initial_value="0" name="q_aux_y" units="metre"/>
        <variable initial_value="9.81" name="g" units="m_per_s2"/>
        <math xmlns="http://www.w3.org/1998/Math/MathML">
            <apply>
                <eq/>
                <ci>u_x_1</ci>
                <apply>
                    <times/>
                    <ci>E_1</ci>
                    <ci>q_aux_x</ci>
                </apply>
            </apply>
            <apply>
                <eq/>
                <ci>u_y_1</ci>
                <apply>
                    <times/>
                    <ci>E_2</ci>
                    <ci>q_aux_y</ci>
                </apply>
            </apply>
            <apply>
                <eq/>
                <apply>
                    <diff/>
                    <bvar>
                        <ci>t</ci>
                    </bvar>
                    <ci>q_aux_x</ci>
                </apply>
                <ci>v_aux_x</ci>
            </apply>
            <apply>
                <eq/>
                <apply>
                    <diff/>
                    <bvar>
                        <ci>t</ci>
                    </bvar>
                    <ci>q_aux_y</ci>
                </apply>
                <ci>v_aux_y</ci>
            </apply>
            <apply>
                <eq/>
                <ci>u_g_1</ci>
                <apply>
                    <times/>
                    <ci>I_1</ci>
                    <ci>g</ci>
                </apply>
            </apply>
        </math>
    </component>
    <connection>
        <map_components component_1="control" component_2="pendulum"/>
        <map_variables variable_1="t" variable_2="t"/>
        <map_variables variable_1="q_theta_1" variable_2="q_theta_1"/>
        <map_variables variable_1="l_1" variable_2="l_1"/>
        <map_variables variable_1="I_1" variable_2="I_1"/>
        <map_variables variable_1="q_x_1_tmp" variable_2="q_x_1"/>
        <map_variables variable_1="q_y_1_tmp" variable_2="q_y_1"/>
        <map_variables variable_1="q_xc_1_tmp" variable_2="q_xc_1"/>
        <map_variables variable_1="q_yc_1_tmp" variable_2="q_yc_1"/>
        <map_variables variable_1="q_x_2_tmp" variable_2="q_x_2"/>
        <map_variables variable_1="q_y_2_tmp" variable_2="q_y_2"/>
    </connection>
</model>